﻿using System.Windows;
using System.Collections.ObjectModel;
using STeaL.Algorithm;

namespace SetOperations
{
    /// <summary>
    /// MainWindow.xaml の相互作用ロジック
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = data_;
        }
        private void u_click(object sender, RoutedEventArgs e) {
          data_.Result.Clear();
          foreach ( int item in data_.Mul2.set_union(data_.Mul3) ) {
            data_.Result.Add(item);
          }
        }
        private void i_click(object sender, RoutedEventArgs e) {
          data_.Result.Clear();
          foreach ( int item in data_.Mul2.set_intersection(data_.Mul3) ) {
            data_.Result.Add(item);
          }
        }
        private void d_click(object sender, RoutedEventArgs e) {
          data_.Result.Clear();
          foreach ( int item in data_.Mul2.set_difference(data_.Mul3) ) {
            data_.Result.Add(item);
          }
        }
        private void s_click(object sender, RoutedEventArgs e) {
          data_.Result.Clear();
          foreach ( int item in data_.Mul2.set_symmetric_difference(data_.Mul3) ) {
            data_.Result.Add(item);
          }
        }
        private BindData data_ = new BindData();
    }

    class BindData {
      public BindData() {
        Mul2   = new ObservableCollection<int>();
        Mul3   = new ObservableCollection<int>();
        Result = new ObservableCollection<int>();
        for ( int i = 0; i < 20; ++i ) {
          Mul2.Add(i*2);
          Mul3.Add(i*3);
        }
      }
      public ObservableCollection<int> Mul2   { get; private set; }
      public ObservableCollection<int> Mul3   { get; private set; }
      public ObservableCollection<int> Result { get; private set; }
    }
}
